package com.chh.pdapp.rule.query;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chh.pdapp.assembler.RuleAssembler;
import com.chh.pdclient.dto.data.RuleVO;
import com.chh.pdclient.dto.query.RuleListByParamQuery;
import com.chh.pddomain.gateway.RuleGateway;
import com.chh.pddomain.rule.RuleEntity;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Component
@AllArgsConstructor
public class RuleListByParamQueryExe {

    private final RuleGateway ruleGateway;

    public IPage<RuleVO> execute(RuleListByParamQuery query) {
        IPage<RuleEntity> page = ruleGateway.page(query);

        return page.convert(RuleAssembler::toRuleVO);
    }
}
